package com.example.smartcity_40.Outpatient.apter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.smartcity_40.Outpatient.DepartmentActivity;
import com.example.smartcity_40.Outpatient.ModifyVisitorActivity;
import com.example.smartcity_40.Outpatient.bean.OutpatienttypeBean;
import com.example.smartcity_40.Outpatient.bean.VisitorBean;
import com.example.smartcity_40.R;
import com.example.smartcity_40.tool.Tool;
import com.google.gson.Gson;

import java.util.List;

public class OutpatienttypeApter extends  RecyclerView.Adapter<OutpatienttypeApter.Myhot> {

    private Context context;
    private List<OutpatienttypeBean.RowsBean> list;

    public OutpatienttypeApter(Context context) {
        this.context = context;
    }

    public void setDate(List<OutpatienttypeBean.RowsBean> list){
        this.list = list;
    }
    @NonNull
    @Override
    public OutpatienttypeApter.Myhot onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.l_item_outpatienttype, null);
        return new OutpatienttypeApter.Myhot(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull OutpatienttypeApter.Myhot holder, int position) {
        try {


            String serviceName = list.get(position).getCategoryName();
            if(!TextUtils.isEmpty(serviceName)){
                holder.categoryName.setText(serviceName);
            }

            Double address = list.get(position).getMoney();
            if(address !=null){
                holder.money.setText("收费 "+address);
            }


            holder.relayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent integer = new Intent(context, DepartmentActivity.class);
                   // integer.putExtra("hospitalid",String.valueOf(list.get(position).getId()));
                    context.startActivity(integer);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    class Myhot extends RecyclerView.ViewHolder{

        private final TextView money;
        private final TextView categoryName;
        private final RelativeLayout relayout;

        public Myhot(@NonNull View itemView) {
            super(itemView);
            categoryName = itemView.findViewById(R.id.categoryName);
            money = itemView.findViewById(R.id.money);
            relayout = itemView.findViewById(R.id.relayout);
        }
    }
}



